import { RegisterErrGet, LoginErrGet, SysadminGet, SysadminDelete, SysadminPost, SearchGet, StatusPost, SysadminTreeGet, RegisterAllGet, LoginGetVercode, LoginGetAllData, PeoplePut } from "@/urtil/regester"
//获取注册全部数据
const RegisterAll = query => {
    return new Promise((resolve, reject) => {
        RegisterAllGet("http://47.94.4.201/index.php/index/index/register", query).then(val => {
            val.data.push(query)
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理注册错误结果
const RegisterErr = query => {
    return new Promise((resolve, reject) => {
        RegisterErrGet("/index.php/index/index/geterror", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理登录数据
const LoginAllData = query => {
    return new Promise((resolve, reject) => {
        LoginGetAllData("http://47.94.4.201/index.php/index/index/login", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理修改
const PeoplePutData = query => {
    return new Promise((resolve, reject) => {
        PeoplePut("http://47.94.4.201/index.php/index/role/uproles", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理登录错误结果
const LoginErr = query => {
    return new Promise((resolve, reject) => {
        LoginErrGet("/index.php/index/index/getfaild", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理登录验证码
const LoginVercode = query => {
    return new Promise((resolve, reject) => {
        LoginGetVercode("http://47.94.4.201/index.php/index/index/getcode", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理获取全部角色列表
const GetSysadmin = query => {
    return new Promise((resolve, reject) => {
        SysadminGet("http://47.94.4.201/index.php/index/role/getroleslist", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理添加角色列表
const PostSysadmin = query => {
    return new Promise((resolve, reject) => {
        SysadminPost("http://47.94.4.201/index.php/index/role/addroles", query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理角色删除列表
const DeleteSysadmin = query => {
    return new Promise((resolve, reject) => {
        SysadminDelete('http://47.94.4.201/index.php/index/role/delroles', { id: query }).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理模糊搜索角色列表
const SearchSysadmin = query => {
    return new Promise((resolve, reject) => {
        SearchGet('http://47.94.4.201/index.php/index/role/getsearchroles', { rolename: query }).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理角色状态接口
const SysadminStatus = params => {
    return new Promise((resolve, reject) => {
        StatusPost('http://47.94.4.201/index.php/index/role/stoproles', params).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
//处理角色权限树
const SysadminTree = query => {
    return new Promise((resolve, reject) => {
        SysadminTreeGet('http://47.94.4.201/index.php/index/call/getmenu', query).then(val => {
            resolve(val)
        }).catch((err) => {
            reject(err);
        })
    })
}
export default {
    RegisterAll,//注册全部数据
    RegisterErr,//注册错误结果
    LoginErr,//处理登录错误结果
    GetSysadmin,//获取全部角色列表
    PostSysadmin,//处理角色添加
    DeleteSysadmin,//处理删除角色列表
    SearchSysadmin,//处理模糊搜索角色列表
    SysadminStatus,//处理角色状态
    SysadminTree,//处理角色权限树
    LoginAllData,//处理登录数据
    LoginVercode,//登录验证码
    PeoplePutData,//处理修改
}